import {Singleton} from "../misc/Singleton";
import {BaseGameEntity as Entity} from "./BaseGameEntity";


type EntityMap = Map<number, Entity> ;

export class EntityManager extends Singleton {

    //to facilitate quick lookup the entities are stored in a std::map, in which
    //pointers to entities are cross referenced by their identifying number
    private _entityMap: EntityMap = new Map<number, Entity>();

    registerEntity(entity:Entity) {
        this._entityMap.set(entity.id, entity);
    }

    getEntityFromID(id:number) {
        return this._entityMap.get(id);
    }

    removeEntity(entity:Entity) {
        this._entityMap.delete(entity.id);
    }
}

export const EntityMgr = <EntityManager>EntityManager.instance;
// export default EntityMgr;